<template>
    <scroll id="tabMenu">
      <div class="menu-list">
      <div class="menu-list-item" v-for="(item,index) in categories" :key="index" @click="itemClick(index)" :class="{'menu-list-item-active':currentIndex === index}">
        {{item.title}}
      </div>
      </div>
    </scroll>
</template>

<script>
  import Scroll from '../../../components/common/scroll/Scroll.vue'
  export default {
    name:"TabMenu",
    components:{
      Scroll
    },
    props:{
      categories:{
        type:Array,
        default:[]
      }
    },
    data(){
      return {
        currentIndex:0
      }
    },
    methods:{
      itemClick(index){
        this.currentIndex = index
        this.$emit('selectItem', index)
      }
    }
  }
</script>

<style scoped>
  #tabMenu {
    width: 100px;
    background-color: #f6f6f6a4;
    margin-top: 46px;
    height: calc(100vh - 44px - 49px);
    box-sizing: border-box;
    /* 要将溢出的内容隐藏，不然高度计算在内 */
    overflow: hidden;
  }

  .menu-list-item {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 16px;
    font-weight: 550;
    cursor: pointer;
  }

  .menu-list-item-active {
    font-weight: 700;
    background-color: #fff;
    color: var(--color-high-text);
    border-left: 3px solid var(--color-high-text);
  }
</style>